# -*- coding:utf-8 -*-
from __future__ import unicode_literals

from wenlincms.utils.cache import (cache_key_prefix, cache_installed, cache_get, cache_set)

from mainsys.settings import WEBSITE_CONF


def sitesettings(request=None):
    settings_dict = None
    cache_settings = request and cache_installed()
    cache_key = ""
    if cache_settings:
        cache_key = cache_key_prefix(request) + "context-sitesettings"
        settings_dict = cache_get(cache_key)
    if not settings_dict:
        settings_dict = WEBSITE_CONF
        if cache_settings:
            cache_set(cache_key, settings_dict)
    return {"sitesettings": settings_dict}
